package com.gao.controller;

import com.gao.annontation.StarAuthenticated;
import com.gao.util.JwtUtils;
import com.gao.util.ResultVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gao
 * @time 2022/11/25 11:29:15
 */
@RestController
public class AuthController {

    @RequestMapping("auth/verify")
    public ResultVO verify(@RequestBody String token) {
        boolean b = JwtUtils.verifyToken(token);
        return b ? ResultVO.success() : ResultVO.failure();
    }

    @RequestMapping("auth/getPermissionsByToken")
    public ResultVO getPermissionsByToken(@RequestBody String token) {
        List<String> permissions = JwtUtils.getPermissions(token);
        return ResultVO.success(permissions);
    }

}
